package Decorateur;

import Composite.Dossier;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import javax.swing.tree.*;
import support.Design;


public class MyVerificationTypeCellRenderer implements TreeCellRenderer {
    
    private TreeCellRenderer next;
    private static ImageIcon always=new ImageIcon("spyIconPetit.png");
    private static ImageIcon never=new ImageIcon("neverIconPetit.png");
    
    public MyVerificationTypeCellRenderer(TreeCellRenderer next) {
        
        this.next=next;
    }
    
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        
        Component c=next.getTreeCellRendererComponent(tree,value,selected,expanded,leaf,row,hasFocus);

        DefaultMutableTreeNode t=(DefaultMutableTreeNode)value;
        Dossier f=(Dossier)t.getUserObject();
        File fichier=f.getFichierCourant();
        ImageIcon avant;
        JLabel iconLabel=new JLabel();
        FlowLayout presentation=new FlowLayout();
        JPanel panneau=new JPanel(presentation);
        presentation.setHgap(4);
        presentation.setVgap(1);
        boolean valeurVerification=f.getVerification();
        if(fichier!=null){
            if(valeurVerification==true){
                avant=this.always;
            } else{
                avant=this.never;
            } 
            iconLabel.setIcon(avant);
        }
        panneau.setBackground(Color.WHITE);
        panneau.add(iconLabel);
        panneau.add(c);
        panneau.setBackground(Design.getJTreeColor());       
        
        return panneau;
    }
    
    
    
}
